package com.solution.wx.bizman.customer.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.solution.admin.auth.entity.UserEntity;
import com.solution.admin.auth.service.UserService;
import com.solution.admin.customer.entity.CustomerEntity;
import com.solution.admin.customer.service.CustomerService;
import com.solution.admin.settings.entity.KeyMapEntity;
import com.solution.admin.settings.service.KeyMapService;
import com.solution.common.constants.PublicStatus.USER_APPROVE_STATUS;
import com.solution.common.controller.BaseController;
import com.solution.common.page.JSONGrid;
import com.solution.common.page.PageBean;
import com.solution.common.page.PageParam;
import com.solution.wx.common.constants.PublicConstants;

/**
 * 微信商户端首页控制层
 * @author: solin
 * @date: 2017年12月27日 下午2:05:25
 */
@RequestMapping("/wx/bizman")
@Controller("wxBizmanCustomerController")
public class CustomerController extends BaseController{
	
	@Autowired
	private CustomerService customerService;
	@Autowired
	private KeyMapService keyMapService;
	@Autowired
	private UserService userService;
	
	/**
	 * 跳转到客户待审核页面
	 * @param request
	 * @return
	 * @author: solin
	 * @date: 2018年1月1日 下午10:25:30
	 */
	@RequestMapping("/toPendingApprovalPage")
	public String toPendingApprovalPage(HttpServletRequest request) {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("status", USER_APPROVE_STATUS.PENDING.getId());
		List<CustomerEntity> customerList = customerService.listCustomer(paramMap);
		request.setAttribute("customerList", customerList);
		return "wx/bizman/customer/pendingApproval";
	}
	
	/**
	 * 跳转到指定业务员页面
	 * @param request
	 * @return
	 * @author: solin
	 * @date: 2018年1月2日 上午11:40:17
	 */
	@RequestMapping("/toSetSalesmanPage")
	public String toSetSalesmanPage(HttpServletRequest request) {
		String keyType = "salesmanRoleId";
		List<KeyMapEntity> keyMapEntities = keyMapService.listKeyMap(keyType);
		String salesmanRoleId = keyMapEntities.get(0).getKeyValue();
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("roleId", salesmanRoleId);
		List<UserEntity> salesmanList = userService.getSalesmanList(paramMap);
		request.setAttribute("salesmanList", salesmanList);
		return "wx/bizman/customer/setSalesman";
	}
}

